package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 线下订单的相关枚举
 */
public class OfflineOrderConstant {

    /**
     * 支付方式（0余额，1微信，2支付宝,3银行线下,4现金支付,5积分支付,6积分+余额支付,7积分+微信支付,8积分+支付宝支付）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum PayMode implements IntegerEnum<Integer> {
        WE_CHAT(0, "微信"),
        ALIPAY(1, "支付宝"),
        MONEY(2, "现金"),
        WE_CHAT_MONEY(3, "微信+现金"),
        ALIPAY_MONEY(4, "支付宝+现金"),
        OTHER(5, "其他支付"),

        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        PayMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OfflineOrderConstant.PayMode getByCode(int code) {
            for (OfflineOrderConstant.PayMode value : OfflineOrderConstant.PayMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     *
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum IncomeType implements IntegerEnum<Integer> {
        DIRECT_PUSH_USER(0, "消费者直推奖励"),
        CONSUMER_REGIMENT(1, "消费者团长奖励"),
        CONSUMER_INTERPOSITION_REGIMENT(2, "消费者间接团长奖励"),
        CONSUMER_TERRITORIAL(3,"消费者属地分润奖励"),

        SHOP_DIRECT_PUSH_USER(4,"商家直推奖励"),
        SHOP_CONSUMER_REGIMENT(5, "商家团长奖励"),
        SHOP_CONSUMER_INTERPOSITION_REGIMENT(6, "商家间接团长奖励"),
        SHOP_CONSUMER_TERRITORIAL(7,"商家属地分润奖励"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        IncomeType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OfflineOrderConstant.IncomeType getByCode(int code) {
            for (OfflineOrderConstant.IncomeType value : OfflineOrderConstant.IncomeType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
